fix: double free in checkout_tree_at_recurse
authorDaniel Hast <hast.daniel@protonmail.com>
Fri, 29 Aug 2025 18:17:15 +0000 (14:17 -0400)
committerDaniel Hast <hast.daniel@protonmail.com>
Fri, 29 Aug 2025 18:17:15 +0000 (14:17 -0400)
commita7e2650205b014db375fca3b0cdef9e4b316d0a1
treedec679d42e5c751df0806ee1844b59e90f2e8cb5
parent971a037ea0d792e7535f3c62cb031f5b1b5ad2dd
fix: double free in checkout_tree_at_recurse

Both `xattrs` and `modified_xattrs` are declared with `g_autoptr`, but
`xattrs` is later simply assigned to be equal to `modified_xattrs`,
meaning the automatic cleanup is a double-free.

This is fixed by instead using `g_steal_pointer` to assign the old value
of `xattrs` to a temporary variable, which is used to create the new
value.

I believe this is the cause of issue #3303, and this should fix #3303.
(I can consistently reproduce the issue by attempting to deploy a
rechunked image with bootc, and with this patch, the issue no longer
occurs and the deployment succeeds.)

Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
src/libostree/ostree-repo-checkout.c